package com.jg.scheduler;

import com.jg.service.InventoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * @author 86130
 * @version 1.0
 * @description: TODO
 * @date 2025/10/16 8:41
 */
@Component
public class InventoryScheduler {
    @Autowired
    private InventoryService inventoryService;

    //每一小时查询库存列表，如果库存低于预警值，则发送消息
    @Scheduled(cron = "0 */1 * * * ?")
    public void inventoryScheduler() {
        System.out.println("开始定时库存检查..." + LocalDateTime.now());
        inventoryService.checkInventoryAndSendWarning();
    }
}